﻿using System;
using System.Collections.Generic;
using System.Web;

namespace Util
{
    public static class QueryStringHelper
    {
        /*public static Tip GetQueryString(string strName)
        {
            Tip deger;
            try
            {
                if (HttpContext.Current.Request.QueryString[strName] != null)
                    deger = (Tip)(HttpContext.Current.Request.QueryString[strName]);
                else
                    deger = -1;
            }
            catch
            {
                Util.Common.HataSayfasinaYonlendir(Enums.EHatalar.POPUP_HATALI_PARAMETRE);
                throw new ArgumentException();
            }

            return deger;
        }*/

        public static int GetQueryStringByInt(string strName)
        {
            int deger;
            try
            {
                if (HttpContext.Current.Request.QueryString[strName] != null)
                    deger = Convert.ToInt32(HttpContext.Current.Request.QueryString[strName]);
                else
                    deger = -1;
            }
            catch
            {
                throw new ArgumentException();
            }

            return deger;
        }

        public static int? GetQueryStringByNullableInt(string strName)
        {
            int? deger;
            try
            {
                if (HttpContext.Current.Request.QueryString[strName] != null)
                    deger = Convert.ToInt32(HttpContext.Current.Request.QueryString[strName]);
                else
                    deger = null;
            }
            catch
            {
                throw new ArgumentException();
            }

            return deger;
        }

        public static string GetQueryStringByString(string strName)
        {
            string deger;
            try
            {
                if (HttpContext.Current.Request.QueryString[strName] != null)
                    deger = HttpContext.Current.Request.QueryString[strName];
                else
                    deger = String.Empty;
            }
            catch
            {
                throw new ArgumentException();
            }

            return deger;
        }
    }
}